package com.huike.web.controller.system;

import com.huike.clues.domain.SysDictData;
import com.huike.clues.service.ISysDictDataService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @version: 1.0
 * @Author: ljy
 * @description:
 * @date: 2025-08-11 21:00
 */

@RestController
@RequestMapping("/system/dict")
@Slf4j
public class SysDictDataController extends BaseController {

    @Autowired
    private ISysDictDataService sysDictDataService;


    /**
     * 获取字典选择框列表
     * @return
     */
    @GetMapping("/type/optionselect")
    public AjaxResult optionselect() {
        List<SysDictData> sysDictDataList = sysDictDataService.list();
        return sysDictDataList != null ? AjaxResult.success(sysDictDataList) : AjaxResult.error();
    }


    /**
     * 根据字典类型查询字典数据信息
     * @param dictType
     * @return
     */
    @GetMapping("/data/type/{dictType}")
    public AjaxResult queryDictsByDictType(@PathVariable String dictType) {
        List<SysDictData> sysDictDataList = sysDictDataService.queryDictsByDictType(dictType);
        return sysDictDataList != null ? AjaxResult.success(sysDictDataList) : AjaxResult.error();
    }
}
